from .trigger import ObjectEnterTrigger, ObjectLeaveTrigger


# 进入报警器
class EnterTrigger(ObjectEnterTrigger):
    
    def enter(self, obj, objs):
        self.alert_to_cloud({
            'type': obj.label,
            'target': f'{obj.label}出现',
            'action': 1,
            'image': {
                'base64': self.encode_jpg_image(obj.make_shotcut()),
                'ext': 'jpg'
            }
        })

# 离开报警器
class LeaveTrigger(ObjectLeaveTrigger):
    
    def leave(self, obj, objs):
        self.alert_to_cloud({
            'type': obj.label,
            'target': f'{obj.label}离开',
            'action': 2,
            'image': {
                'base64': self.encode_jpg_image(obj.make_shotcut()),
                'ext': 'jpg'
            }
        })
